/***************************************************************************
 *   Copyright (C) 2008 by Chris Vickery   *
 *   chrisinajar@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include "spaceship.h"
#include <qmath.h>
#include <QDebug>


SpaceShip::SpaceShip(QObject *parent) :
		QObject(parent),
		x(0),
		y(0),
		width(10),
		height(10),
		angle(0),
		xv(0),
		yv(0)
{
}

SpaceShip::~SpaceShip()
{
}

void SpaceShip::rotate(int r)
{
	angle += ((double)r / 100.0);
}

void SpaceShip::accelerate(int a)
{
	int xd, yd;
	yd = qCos(angle) * a;
	yd /= 10;
	xd = qSin(angle) * a;
	xd /= 10;
	xv += xd;
	yv += yd;
	qDebug() << "xv" << xv << "Yv" << yv;
	qDebug() << "xd" << xd << "Yd" << yd;
}

// sin o/h cos a/h tan o/a
void SpaceShip::tick(int time)
{
	x += (xv * time) / 1000;
	y += (yv * time) / 1000;
	qDebug() << "Tick time: " << time << "x" << x << "Y" << y;
}

int SpaceShip::getX()
{
	return x;
}

int SpaceShip::getY()
{
	return y;
}

int SpaceShip::getAngle()
{
	return angle;
}

int SpaceShip::getWidth()
{
	return width;
}

int SpaceShip::getHeight()
{
	return height;
}


